<!--
 * @Autor: dingxiaolin
 * @Date: 2021-05-13 17:12:38
 * @LastEditors: dingxiaolin
 * @LastEditTime: 2021-05-18 10:54:36
-->
<template>
    <div class="select">
        <div @click="showStock = true" class="color" style="position: relative">{{ stockType }} <i class="sanjiao"></i></div>
        <van-popup v-model:show="showStock" round position="bottom">
            <van-picker
                title="选择仓库"
                :columns="props.stockList"
                @cancel="showStock = false"
                :defaultIndex="defaultStock"
                @confirm="confirmStock"
            />
        </van-popup>
    </div>
</template>

<script lang="ts">
import { defineComponent, PropType, reactive, toRefs, inject, computed, nextTick, onMounted } from 'vue';
import { useRouter } from 'vue-router';

export default defineComponent({
    name: 'Stock',
    components: {},
    props: { stockList: Array },
    emits: ['emit'],
    setup(props, ctx) {
        const router = useRouter();
        const state = reactive({
            showStock: false,
            defaultStock: 0,
            stockType: '全部',
        });
        onMounted(() => {});
        function confirmStock(value, index) {
            state.stockType = value;
            state.showStock = false;
            ctx.emit('emit', state.stockType);
        }
        return {
            ...toRefs(state),
            confirmStock,
            props,
        };
    },
});
</script>

<style lang="scss" scoped>
</style>
